<template>
  <div class="content">
    <div
      ref="charts"
      style="width: 500px; height: 400px;"
    />
  </div>
</template>

<script>
import * as echarts from 'echarts'
import { getEchartsPie } from '@/api/mockEcharts'
export default {
  name: 'EchartsPie',
  mounted() {
    this.initCharts()
  },
  methods: {
    async initCharts() {
      const res = await getEchartsPie()
      this.list = res.data.list
      const charts = echarts.init(this.$refs['charts'])
      const option = {
        title: {
          text: '活动管理',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        // legend: {
        //   orient: 'vertical',
        //   left: 'left'
        // },
        series: [
          {
            label: {
              show: false
            },
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: this.list,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      charts.setOption(option)
    }
  }
}
</script>

  <style>

  </style>

